#!/bin/sh
#
# Copyright (C) 2000-2022 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# Run a simple backup of the Bacula build directory
#   then restore it.
# We have bad configuration for Messages resources, everything
# should work
#
TestName="messages-test"
JobName=backup
. scripts/functions

# turn off until the email problem is solved
exit 0

scripts/cleanup
scripts/copy-confs
change_jobname BackupClient1 $JobName
start_test
#
# Zap out any schedule in default conf file so that
#  it doesn't start during our test
#
outf="$tmp/sed_tmp"
echo "s%  Schedule =%# Schedule =%g" >$outf

# tweak all Messages {} with non valid path
echo 's%append = "%append = "/nowhere%g' >> $outf
echo "s%bsmtp -h $SMTP_HOST%bsmtp -h nonvalidhost%g" >> $outf
echo 's%# mail%  mail%' >> $outf
echo 's%Bacula daemon message%DELETE THIS MESSAGE Bacula daemon message%' >> $outf
echo 's%Bacula:%DELETE THIS MESSAGE Bacula:%' >> $outf
#echo 's%mailcommand = "%mailcommand = "/nowhere%g' >> $outf

cp $scripts/bacula-dir.conf $tmp/1
sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf


cat <<END_OF_DATA >$tmp/bconcmds
@output /dev/null
messages
@$out $tmp/log1.out
@#setdebug level=100 storage=File
label volume=TestVolume001 storage=File pool=File
run job=$JobName yes
@sleep 1
status storage=File
wait
messages
@# 
@# now do a restore
@#
@$out $tmp/log2.out  
restore where=$tmp/bacula-restores select all done
yes
wait
messages
quit
END_OF_DATA

run_bacula
check_for_zombie_jobs storage=File
stop_bacula

check_two_logs
check_restore_diff
end_test
